const express = require("express")
router = express.Router()
const async = require("async")
const Article = require("../mongodb/article")

//设置一些状态
let result = { status: 200, data: null, state: "成功" }

router.get("/article", async (req, res) => {
    try {
        let data = await Article.find({})
        result.data = data
        res.send(result)
        return
    }

    catch {
        console.log(err)
        result.status = 500
        result.state = "失败"
        res.status = 500
        res.state = "服务器错误"
        res.send(result)
    }

})

module.exports = router